<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="content">
            <h:form >
                <p:panel id="payments" header="All Normal Payments" >
                    <p:dataTable value="#{paymentEntityController.normalPayments}" var="item" 
                                 paginator="true" rows="30" rowsPerPageTemplate="30,50,100">
                        <p:column filterBy="#{item.id}" sortBy="#{item.id}">
                            <f:facet name="header">
                                <h:outputText value="Payment ID"/>
                            </f:facet>
                            <h:outputText value="#{item.id}"/>
                        </p:column>
                        
                        <p:column filterBy="#{item.invoice.id}" sortBy="#{item.invoice.id}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListPaymentEntityTitle_invoice}"/>
                            </f:facet>
                            <h:outputText value="#{item.invoice.id}"/>
                        </p:column>

                        <p:column filterBy="#{item.invoice.billingRequest.salesOrder.id}" sortBy="#{item.invoice.billingRequest.salesOrder.id}">
                            <f:facet name="header">
                                <h:outputText value="Sales Order"/>
                            </f:facet>
                            <h:commandLink value="#{item.invoice.billingRequest.salesOrder.id}" action="/entities/salesOrderEntity/View">
                                <f:setPropertyActionListener target="#{salesOrderEntityController.current}" value="#{item.invoice.billingRequest.salesOrder}" />
                                <f:setPropertyActionListener target="#{purchaseOrderEntityController.current}" value="#{item.invoice.billingRequest.salesOrder.purchaseOrder}" />
                            </h:commandLink>
                        </p:column>

                        <p:column filterBy="#{item.invoice.billingRequest.salesOrder.customer.fullname}" sortBy="#{item.invoice.billingRequest.salesOrder.customer.fullname}">
                            <f:facet name="header">
                                <h:outputText value="Customer"/>
                            </f:facet>
                            <h:outputText value="#{item.invoice.billingRequest.salesOrder.customer.fullname}"/>
                        </p:column>

                        <p:column filterBy="#{item.createdAt}" sortBy="#{item.createdAt}">
                            <f:facet name="header">
                                <h:outputText value="Payment Date"/>
                            </f:facet>
                            <h:outputText value="#{item.createdAt}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                        </p:column>

                        <p:column filterBy="#{item.createdBy.fullname}" sortBy="#{item.createdBy.fullname}">
                            <f:facet name="header">
                                <h:outputText value="Handled By"/>
                            </f:facet>
                            <h:outputText value="#{item.createdBy.fullname}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="View"/>
                            </f:facet>
                            <p:commandButton image="ui-icon ui-icon-search" action="#{customerInvoiceEntityController.prepareView}" ajax="false">
                                <f:setPropertyActionListener target="#{customerInvoiceEntityController.current}" value="#{item.invoice}" />
                            </p:commandButton>
                        </p:column>
                        
                    </p:dataTable>
                </p:panel>
                
            </h:form>
        </ui:define>
    </ui:composition>

</html>
